package cz.oplevka.lahvodroid;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MyListView extends ListActivity {
    
    private static String beer;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, Lahvodroid.getXmlBeerList().getJmeno()));
        getListView().setTextFilterEnabled(true);
        
    }  
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
    	super.onListItemClick(l, v, position, id);
    	Object o = this.getListAdapter().getItem(position);
    	beer = o.toString();
        Intent intent = new Intent(this, MapView.class);                                
                                startActivity(intent);
    	Toast.makeText(this, "Vybral jste pivo: " + beer, Toast.LENGTH_SHORT).show();
    }
    
    @Override
    public void onResume(){
        super.onResume();
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, Lahvodroid.getXmlBeerList().getJmeno()));
        getListView().setTextFilterEnabled(true);                
    }

    /**
     * @return the beer
     */
    public static String getBeer() {
        return beer;
    }
}